#pragma once

#include "LvDevice.hpp"

// libs
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>

#include <vector>

class LvModel
{
public:
	struct Vertex
	{
		glm::vec3 position{};
		glm::vec3 color{};

		static std::vector<VkVertexInputBindingDescription> getBindingDescriptions();
		static std::vector<VkVertexInputAttributeDescription> getAttributeDescriptions();
	};

	struct Builder
	{
		std::vector<Vertex> vertices{};
		std::vector<uint32_t> indices{};
	};

	LvModel(LvDevice& device, const Builder& builder);
	~LvModel();

	LvModel(const LvModel&) = delete;
	LvModel& operator=(const LvModel&) = delete;

	void bind(VkCommandBuffer commandBuffer);
	void draw(VkCommandBuffer commandBuffer);

private:
	void createVertexBuffers(const std::vector<Vertex>& vertices);
	void createIndexBuffers(const std::vector<uint32_t>& indices);

	LvDevice& lvDevice;

	VkBuffer vertexBuffer { };
	VkDeviceMemory vertexBufferMemory { };
	uint32_t vertexCount { 0 };

	bool hasIndexBuffer { false };
	VkBuffer indexBuffer{};
	VkDeviceMemory indexBufferMemory{};
	uint32_t indexCount{ 0 };
};

